<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #box {
        width: 200px;
        height: 200px;
        background-color: #6ff;
        border: 2px solid transparent;
    }
    .active{
        border-color: pink!important;
    }
</style>
<body>
    <div id="box" class="one two" title="hello"></div>
</body>
<script>
    var box = document.getElementById("box");
    console.dir(box);
    console.log(box.classList);
    box.classList.add("three","four");          //class名的增
    box.classList.remove("one");                //class名的删
    box.classList.replace("two","first");       //class名的改
    var flag = box.classList.contains("first"); //class名的查
    console.log(flag);
    box.onclick = function(){
        box.classList.toggle("active");         //class名存在就删除，不存在就增加
    }

</script>
</html>